home *** CD-ROM | disk | FTP | other *** search
/ CD BIT 75 / CD BIT 75.iso / Software / ooo / f_0020 / sbasic.jar / text / sbasic / common / 03090101.xml < prev    next >
Encoding:
Extensible Markup Language  |  2003-08-01  |  7.3 KB  |  59 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <html><head><title>If...Then...Else Statement [Runtime]</title><meta name="filename" content="text/sbasic/common/03090101"/><help:css-file-link xmlns:help="http://openoffice.org/2000/help"/><!--The CSS style header method for setting styles--><style type="text/css">
  3.  
  4.         table.Tabelle1{
  5.                 }
  6.         span.Tabelle1A{
  7.                 width:1.499cm;}
  8.         span.Tabelle1B{
  9.                 width:16.498cm;}
  10.         tr.Tabelle11{
  11.                 }
  12.         td.Tabelle1A1{
  13.                 }
  14.         p.P1{
  15.                 }
  16.         span.T1{
  17.                 font-weight:bold;}
  18.         span.fr1{
  19.                 }
  20.         </style></head><body>
  21.   
  22.   
  23.   <help:paragraphinfo state="E" xmlns:help="http://openoffice.org/2000/help"/><help:to-be-embedded Eid="ifthenelse" xmlns:help="http://openoffice.org/2000/help">
  24.   <p class="Head1"><help:paragraphinfo state="U" number="1"/><help:key-word value="If; statement" tag="kw66523_1"/><help:link Id="66523">If...Then...Else Statement [Runtime]</help:link></p>
  25.   <p class="Paragraph"><help:paragraphinfo state="U" number="2"/>Defines one or more statement blocks that you only want to execute if a given condition is True.</p>
  26.   <help:paragraphinfo state="E"/></help:to-be-embedded>
  27.   <p class="Head2"><help:paragraphinfo state="U" number="3" xmlns:help="http://openoffice.org/2000/help"/>Syntax:</p>
  28.   <p class="Paragraph"><help:paragraphinfo state="U" number="4" xmlns:help="http://openoffice.org/2000/help"/>If condition=true Then Statement block [ElseIf condition=true Then] Statement block [Else] Statement block End If</p>
  29.   <p class="Head2"><help:paragraphinfo state="U" number="5" xmlns:help="http://openoffice.org/2000/help"/>Parameters:</p>
  30.   <p class="Paragraph"><help:paragraphinfo state="U" number="6" xmlns:help="http://openoffice.org/2000/help"/>The <span class="T1">If...Then</span> statement executes program blocks depending on given conditions. When <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Basic encounters an <span class="T1">If</span> statement, the condition is tested. If the condition is True, all subsequent statements up to the next <span class="T1">Else</span> or <span class="T1">ElseIf</span> statement are executed. If the condition is False, and an <span class="T1">ElseIf</span> statement follows, <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Basic tests the next condition and executes the following statements if the condition is True. If False, the program continues either with the next <span class="T1">ElseIf</span> or <span class="T1">Else</span> <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>statement. Statements following <span class="T1">Else</span> are executed only if none of the previously tested conditions were True. After all conditions are evaluated, and the corresponding statements executed, the program continues with the statement following <span class="T1">EndIf</span>.</p>
  31.   <p class="Paragraph"><help:paragraphinfo state="U" number="7" xmlns:help="http://openoffice.org/2000/help"/>You can nest multiple <span class="T1">If...Then</span> statements.</p>
  32.   <p class="Paragraph"><help:paragraphinfo state="U" number="8" xmlns:help="http://openoffice.org/2000/help"/><span class="T1">Else</span> and <span class="T1">ElseIf</span> statements are optional.</p>
  33.   <table><tr class="Tabelle11"><th class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1A">
  34.       <p class="TextInTable"><draw:image draw:name="Icon0" svg:desc="This icon marks text containing important information on data and system security." svg:pixelx="32" svg:pixely="32" svg:width="0.847cm" svg:height="0.847cm" xlink:href="65640" draw:filter-name="" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"/></p>
  35.  
  36.      </span></th><th class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1B">
  37.       <p class="TextInTable"><help:paragraphinfo state="U" number="9" xmlns:help="http://openoffice.org/2000/help"/>You can use <span class="T1">GoTo</span> and <span class="T1">GoSub</span> to jump out of an <span class="T1">If...Then</span> block, but not to jump into an <span class="T1">If...Then</span> structure.</p>
  38.      </span></th></tr></table>
  39.   <p class="Paragraph"><help:paragraphinfo state="U" number="10" xmlns:help="http://openoffice.org/2000/help"/>The following example enables you to enter the expiration date of a product, and determines if the expiration date has passed.</p>
  40.   <p class="Head2"><help:paragraphinfo state="U" number="11" xmlns:help="http://openoffice.org/2000/help"/>Example:</p>
  41.   <p class="PropText"><help:paragraphinfo state="U" number="12" xmlns:help="http://openoffice.org/2000/help"/>Sub ExampleIfThenDate</p>
  42.   <p class="PropText"><help:paragraphinfo state="U" number="13" xmlns:help="http://openoffice.org/2000/help"/>Dim sDate as String</p>
  43.   <p class="PropText"><help:paragraphinfo state="U" number="14" xmlns:help="http://openoffice.org/2000/help"/>Dim sToday as String</p>
  44.   <p class="PropText"><help:paragraphinfo state="U" number="15" xmlns:help="http://openoffice.org/2000/help"/></p>
  45.   <p class="PropText"><help:paragraphinfo state="U" number="16" xmlns:help="http://openoffice.org/2000/help"/>sDate = InputBox("Enter the expiration date (MM.DD.YYYY)")</p>
  46.   <p class="PropText"><help:paragraphinfo state="U" number="17" xmlns:help="http://openoffice.org/2000/help"/>sDate = Right$(sDate, 4) + <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>Mid$(sDate, 4, 2) <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>+ Left$(sDate, 2)</p>
  47.   <p class="PropText"><help:paragraphinfo state="U" number="18" xmlns:help="http://openoffice.org/2000/help"/>sToday = Date$</p>
  48.   <p class="PropText"><help:paragraphinfo state="U" number="19" xmlns:help="http://openoffice.org/2000/help"/>sToday = Right$(sToday, 4)+ <text:s text:c="2" xmlns:text="http://openoffice.org/2000/text"/>Mid$(sToday, 4, 2) <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>+ Left$(sToday, 2)</p>
  49.   <p class="PropText"><help:paragraphinfo state="U" number="20" xmlns:help="http://openoffice.org/2000/help"/>If sDate < sToday Then</p>
  50.   <p class="PropText"><help:paragraphinfo state="U" number="21" xmlns:help="http://openoffice.org/2000/help"/>MsgBox "The expiration date has passed"</p>
  51.   <p class="PropText"><help:paragraphinfo state="U" number="22" xmlns:help="http://openoffice.org/2000/help"/>ElseIf sDate > sToday Then</p>
  52.   <p class="PropText"><help:paragraphinfo state="U" number="23" xmlns:help="http://openoffice.org/2000/help"/>MsgBox "The expiration date has not yet passed"</p>
  53.   <p class="PropText"><help:paragraphinfo state="U" number="24" xmlns:help="http://openoffice.org/2000/help"/>Else</p>
  54.   <p class="PropText"><help:paragraphinfo state="U" number="25" xmlns:help="http://openoffice.org/2000/help"/>MsgBox "The expiration date is today"</p>
  55.   <p class="PropText"><help:paragraphinfo state="U" number="26" xmlns:help="http://openoffice.org/2000/help"/>End If</p>
  56.   <p class="PropText"><help:paragraphinfo state="U" number="27" xmlns:help="http://openoffice.org/2000/help"/></p>
  57.   <p class="PropText"><help:paragraphinfo state="U" number="28" xmlns:help="http://openoffice.org/2000/help"/>End Sub</p>
  58.   <p class="PropText"><help:paragraphinfo state="U" number="29" xmlns:help="http://openoffice.org/2000/help"/></p>
  59.  </body></html>